﻿using AutoMapper;
using B.S.Production.Domain.Entities;
using B.S.Production.ErrorCode;
using B.S.Production.Write.API.Application.Command.ProductionOrderCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;


namespace B.S.Production.Write.API.Controllers
{
   /// <summary>
   /// 写-控制器
   /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProductionController : ControllerBase
    {
        private readonly IMediator mediator;

        public ProductionController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 生产订单添加
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public async Task<ApiResult<int>> AddProductionOrder(AddProductionOrderCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpDelete]
        public async Task<ApiResult<int>> DeleteProductionOrder([FromQuery]DeleteProductionOrderCommand command)
        {
            return await mediator.Send(command);
        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="command">实体</param>
        /// <returns></returns>
        /// 
        [HttpPut]
        public async Task<ApiResult<int>> UpdateProductionOrder(UpdateProductionOrderCommand command)
        {
            return await mediator.Send(command);
        }
       
    }
}
